<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .demo {
            background-color: orange;
        }
    </style>
</head>
<body>
    <button id="btn">点击我创建input输入框</button>
    <script text="type/javascript">
        // 获取元素
        let id = document.getElementById('btn');
        // 在元素上面绑定方法
        id.onclick = () => {
            const input =  document.createElement('input');
            input.className = 'demo'
            document.body.appendChild(input)
            console.log(input.parentElement);
            input.parentElement.style.backgroundColor = 'skyblue'
            input.focus()
        }

    </script>
</body>
</html>